package iit.projects.etaxi.view.bean;


import iit.projects.etaxi.model.entity.Vehicle;
import iit.projects.etaxi.model.service.ServiceLocator;
import iit.projects.etaxi.model.service.VehicleService;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class VehicleBackingBean {
	
	final Logger log = LoggerFactory.getLogger(VehicleBackingBean.class);
	
	
	private List<Vehicle> vehicle;
	
	private ServiceLocator serviceLocator;
	
	private VehicleService vehicleService;
	
	
	public VehicleBackingBean() {
	}
	
	@javax.annotation.PostConstruct
	public void init(){
		vehicleService = serviceLocator.getVehicleService();
		searchVehicles();
	}
	
	
	public void searchVehicles(){
		this.vehicle = vehicleService.findVehicles();
		if(this.vehicle == null || this.vehicle.isEmpty()){
			return;
		}
	}

	public void setServiceLocator(ServiceLocator serviceLocator) {
		this.serviceLocator = serviceLocator;
	}


	/**
	 * @param vehicle the vehicle to set
	 */
	public void setVehicle(List<Vehicle> vehicle) {
		this.vehicle = vehicle;
	}

	/**
	 * @return the vehicle
	 */
	public List<Vehicle> getVehicle() {
		return vehicle;
	}

}
